Using a mutex to check if the program is already running.

Add this code to check if the program is already open and close the application to prevent it from running 2 instances of it at the same time.

======================================================

HANDLE hd;

LPCWSTR mu = (LPCWSTR)"MyMutex";
hd = CreateMutexW(NULL, FALSE, mu);
if(GetLastError() == ERROR_ALREADY_EXISTS)
{
    MessageBox::Show("The program is already running.");
    return 1;
}